%%
clc;clear
syms p(n) z Ts T s f zz
assume(n>0 & in(n,'integer'))
assume(T>0)
assume(Ts>0)

%% param set
% Ts = 1e-4;
% Tc = 0.02;

%% s domain to z domain
fs = 1/(T*s+1)*1/(T*s+1)
s_ = (1-z^-1)/Ts
fz = subs(fs, s, s_)
fz = collect(fz,z)

%% z domain to difference equations
syms x y
[n,d] = numden(fz)
equ = d*y==n*x
equ = collect(equ,[x,y,z])

